<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Function template convert</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../boost_convert_c___reference.html#header.boost.convert_hpp" title="Header &lt;boost/convert.hpp&gt;">
<link rel="prev" href="throw_on_failure.html" title="Global throw_on_failure">
<link rel="next" href="convert_idm11787.html" title="Function template convert">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="throw_on_failure.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_convert_c___reference.html#header.boost.convert_hpp"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="convert_idm11787.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.convert_idm11767"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Function template convert</span></h2>
<p>boost::convert — Boost.Convert main deployment interface. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../boost_convert_c___reference.html#header.boost.convert_hpp" title="Header &lt;boost/convert.hpp&gt;">boost/convert.hpp</a>&gt;

</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> TypeOut<span class="special">,</span> <span class="keyword">typename</span> TypeIn<span class="special">,</span> <span class="keyword">typename</span> Converter<span class="special">&gt;</span> 
  <span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span> <span class="identifier">TypeOut</span> <span class="special">&gt;</span> 
  <span class="identifier">convert</span><span class="special">(</span><span class="identifier">TypeIn</span> <span class="keyword">const</span> <span class="special">&amp;</span> value_in<span class="special">,</span> <span class="identifier">Converter</span> <span class="keyword">const</span> <span class="special">&amp;</span> converter<span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm12385"></a><h2>Description</h2>
<p>

For example, </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cnv</span><span class="special">::</span><span class="identifier">cstream</span> <span class="identifier">cnv</span><span class="special">;</span>

<span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span>    <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span><span class="special">(</span><span class="string">"12"</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">)</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">s</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span><span class="special">(</span><span class="number">123</span><span class="special">.</span><span class="number">456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">)</span><span class="special">;</span>
</pre>
<p> </p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">converter</code></span></p></td>
<td><p>Converter to be used for conversion </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">value_in</code></span></p></td>
<td><p>Value of the TypeIn type to be converted to the TypeOut type </p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>boost::optional&lt;TypeOut&gt; result of conversion together with the indication of success or failure of the conversion request.</p></td>
</tr>
</tbody>
</table></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2022 Vladimir
      Batov<p>
        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="throw_on_failure.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_convert_c___reference.html#header.boost.convert_hpp"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="convert_idm11787.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>
